﻿using Autofac.Annotation;
using Microsoft.AspNetCore.Mvc;
using TS.Model;
using TS.Services;

namespace TaskScheduling.Controllers;

[Component]
[Route("/[controller]/[action]")]
public class SshServerController : Controller
{
    [Autowired] public SshServerService _SshServerService { get; set; }

    public async Task<IActionResult> List(SshServerSearchList searchList)
    {
        return Json(await _SshServerService.GetList(searchList));
    }

    public async Task<IActionResult> AddOrUpdate([FromBody] SshServer sshServer)
    {
        return Json(await _SshServerService.AddOrUpdateSshServer(sshServer));
    }

    public async Task<IActionResult> GetOne(SshServer sshServer)
    {
        return Json(await _SshServerService.GetOne(sshServer));
    }

    public async Task<IActionResult> DeleteOne(SshServer sshServer)
    {
        return Json(await _SshServerService.DeleteOne(sshServer));
    }

    public async Task<IActionResult> ExceShell([FromBody] SshServer sshServer)
    {
        return Json(await _SshServerService.ExecShell(sshServer.ID, sshServer.shell));
    }

    public async Task<IActionResult> Select()
    {
        return Json(await _SshServerService.GetSelect());
    }
}